package com.crazyant;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.MenuItem;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;
import android.support.v4.app.NavUtils;

public class Presentacion extends Activity {

	Thread logoTimer;
	boolean stopped;
	
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.carga_piruleta_layout);
        
        //Imatge carrega
      	ImageView carrega = (ImageView)findViewById(R.id.piruleta);
      	carrega.startAnimation(AnimationUtils.loadAnimation(this, R.anim.carga_piruleta));
      	ImageView carrega2 = (ImageView)findViewById(R.id.piruleta2);
      	carrega2.startAnimation(AnimationUtils.loadAnimation(this, R.anim.carga_chups));
      	ImageView carrega3 = (ImageView)findViewById(R.id.piruleta3);
      	carrega3.startAnimation(AnimationUtils.loadAnimation(this, R.anim.carga_chups));
        
        stopped = false;
		logoTimer = new Thread(){
			public void run(){
				try{
					sleep(4000);
					if(!stopped) {
						Intent i = new Intent("com.crazyant.LOGIN");
						startActivity(i);
					}
				} catch (InterruptedException e) {
					e.printStackTrace();
				}
				finally{
					finish();
				}
			}
		};
		logoTimer.start();
    }

    
    @Override
	protected void onStop() {
		super.onStop();
		stopped = true;
		//fer join del thread en el cas de que no estigues dormint
	}
	
	@Override
	public void onBackPressed() {
		finish();
		//activity transition animation
		super.onBackPressed();
	}
}
